package docker

//使用dockerfile构建一个虚悬镜像，即 仓库名,标签都是<none>的镜像
//出现这种镜像，一定要删除

/*

	来源：
		构建镜像或者删除镜像的时候，出现的一些错误，导致仓库[REPOSITORY]和标签[TAG]都是<none>
		遇见这种镜像，一定删除

	目录：
		1.编写一个dockerfile
		2.build 构建镜像
		3.查询本地所有的虚悬镜像
			docker image ls -f dangling=true
		4.删除虚悬镜像
			docker image prune


---------1.编写一个dockerfile---------

随便编写一个dockerfile

Dockerfile

FROM golang:1.19
CMD echo "----is ok----"


---------2.build 构建镜像---------

docker build .




root@VM-4-8-debian:/home/zydh/www/dockerfile_test2# vim Dockerfile
root@VM-4-8-debian:/home/zydh/www/dockerfile_test2# docker build .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM golang:1.19
 ---> 4f7c78c9b46f
Step 2/2 : CMD echo "----is ok----"
 ---> Running in b1b75e384fc8
Removing intermediate container b1b75e384fc8
 ---> 04f067290b55
Successfully built 04f067290b55
root@VM-4-8-debian:/home/zydh/www/dockerfile_test2# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
<none>       <none>    04f067290b55   11 seconds ago   992MB			##REPOSITORY <none> 无镜像，无标签
redis        7.0.5     f8528f17261c   4 days ago       117MB
golang       1.19      4f7c78c9b46f   3 weeks ago      992MB
golang       latest    276895edf967   9 months ago     941MB
redis        latest    7614ae9453d1   9 months ago     113MB
mysql        latest    3218b38490ce   9 months ago     516MB
root@VM-4-8-debian:/home/zydh/www/dockerfile_test2#



---------3.查询本地所有的虚悬镜像---------

root@VM-4-8-debian:/home/zydh/www/dockerfile_test2# docker image ls -f dangling=true
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
<none>       <none>    04f067290b55   6 minutes ago   992MB
root@VM-4-8-debian:/home/zydh/www/dockerfile_test2#


---------4.删除虚悬镜像---------

root@VM-4-8-debian:/home/zydh/www/dockerfile_test2# docker image prune
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:04f067290b55c618410a24553b13a268a2f17ee96cd8db6d52d3c6f0b3cc70fd

Total reclaimed space: 0B
root@VM-4-8-debian:/home/zydh/www/dockerfile_test2# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
redis        7.0.5     f8528f17261c   4 days ago     117MB
golang       1.19      4f7c78c9b46f   3 weeks ago    992MB
golang       latest    276895edf967   9 months ago   941MB
redis        latest    7614ae9453d1   9 months ago   113MB
mysql        latest    3218b38490ce   9 months ago   516MB
root@VM-4-8-debian:/home/zydh/www/dockerfile_test2#



*/
